package com.kasinf.sample.protect.controller;

import com.kasinf.framework.cache.utils.RedisUtils;
import com.kasinf.framework.common.core.BaseConstant;
import com.kasinf.framework.common.pojo.CommonResult;
import com.kasinf.framework.common.util.json.JsonUtils;
import com.kasinf.framework.signature.config.SignMode;
import com.kasinf.framework.signature.core.annotation.ApiSignature;
import com.kasinf.sample.protect.controller.vo.DataInfo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * 签名验签测试
 *
 * @Author : Kaiser
 * @Date: 2025/6/18  08:50
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("sign")
public class SignController {


    @PostMapping("set-app")
    public CommonResult<String> setAppInfo(@RequestParam String appId, @RequestParam String appSecret){
        RedisUtils.setCacheMapValue(BaseConstant.CACHE_APP_SECRET, appId, appSecret);
        return CommonResult.success("添加成功");
    }

    @ApiSignature(mode = SignMode.MD5)
    @GetMapping("test-md5")
    public CommonResult<String> test(DataInfo info) {
        log.info(">>>>>> 收到请求：{}", JsonUtils.toJsonString(info));
        return CommonResult.success("签名验签测试成功");
    }
}
